<?php
class Admin_Models_UserAdminModel extends Zend_Db_Table_Abstract {
	protected $_name = "admin_user";
	protected $_id = "id";
	
	/**
	 * Lấy thông tin user dựa vào username
	 * @param string $username
	 * @return array $user_info
	 */
	function getUserInfoByUsername($username = NULL){
		if (!$username){
			return FALSE;
		}
		$db = Zend_Db_Table::getDefaultAdapter();
		$mySql = $db->select()
					->from(array('u'	=> $this->_name),array('username','salt'))
					->where("username = ?" , $username)
					->where("status = 1");
		$result = $db->fetchRow($mySql);
		return $result;
	}
	/**
	 * Lấy ra tất cả danh sách user có status = 1
	 * @return array $user_list
	 */
	function getAllUserList(){
		$db = Zend_Registry::get('connectDB');
		$mySql = $db->select()
					->from(array('u' => 'admin_user'),array('id','username'))
					->where("status = 1");
		$user_list = $db->fetchAll($mySql);
		return $user_list;
	}	
}